<?php use_stylesheet('home.css') ?>
<?php use_stylesheet('jquery.fancybox-1.3.4.css') ?>

<?php use_javascript('jquery-1.8.2.min.js') ?>
<?php use_javascript('jquery.carouFredSel-6.2.0-packed.js') ?>
<?php use_javascript('helper-plugins/jquery.mousewheel.min.js') ?>
<?php use_javascript('helper-plugins/jquery.touchSwipe.min.js') ?>
<?php use_javascript('helper-plugins/jquery.transit.min.js') ?>
<?php use_javascript('helper-plugins/jquery.ba-throttle-debounce.min.js') ?>
<?php use_javascript('jquery.fancybox-1.3.4.pack.js') ?>


    <section id="sectionWelcome">
        <?php include_component('componente','welcome') ?>
    </section>              


    <section id="bloqueHeader">  <?php include_component('componente','header') ?>    </section>
    <section id="bloqueBaner">      </section>
    <section id="sectionNav"><?php include_component('componente','nav') ?> </section>    
    
    <section id="bloqueBuscador"> <?php include_component('componente','search') ?>    </section>
  
    <section id="sectionBodyHome">
        <div id="contenedor" style="text-align: left;padding-left: 2%;width: 67%;max-width: 833px;background-color: #FFF;">
            <?php if(count($lista)): ?>
            <?php foreach($lista as $row): ?>
            <div id="detalleProducto">
                <div><a href="javascript:mostarDetalle('<?php echo $row->getId(); ?>')">


                <?php if($row->getTipoDocumento()->getDescripcion()=="tesis"){ ?>
                <?php $tipo_principal="tesis.jpg" ?>
                <?php }elseif($row->getTipoDocumento()->getDescripcion()=="investigacion"){ ?>
                <?php $tipo_principal="investigacion.jpg" ?>
                <?php }else{ ?>
                <?php $tipo_principal="presentacion.jpg" ?>
                <?php }?>


                <?php if($row->getImagenPortada()!=''){ ?>
                <?php $DS = DIRECTORY_SEPARATOR; ?>
                <?php if(file_exists(sfConfig::get('sf_upload_dir').$DS."documento".$DS.$row->getImagenPortada())){ ?>
                <?php echo image_tag('/uploads/documento/'.$row->getImagenPortada(),'class="imag_portada" size=152x114'); ?>
                <?php } ?>
                <?php }else { ?>
                        <?php echo image_tag('/uploads/documento/'.$tipo_principal,'class="imag_portada" size=152x114'); ?>
                <?php }?>


                

                </a></div>
                <div>
                    <ul>
                        <li><a href="javascript:mostarDetalle('<?php echo $row->getId(); ?>')"><h2><?php echo strtoupper(  $row->getTitulo() );  ?></h2></a><h3><?php echo $row->getAutor(); ?></h3>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo image_tag('estrellaroja.png') ?>&nbsp;<?php echo image_tag('estrellaroja.png') ?>&nbsp;<?php echo image_tag('estrellaroja.png') ?>&nbsp;<?php echo image_tag('estrellagris.png') ?>&nbsp;<?php echo image_tag('estrellagris.png') ?></li>
                        <li style="height: 85px;overflow: hidden;line-height: 23px;">
                            <p><?php echo strtolower( $row->getResumenDocumento()); ?></p>                            
                        </li>
                        <li><?php echo image_tag('check.png','style=position: relative;top: 6px;') ?>&nbsp;&nbsp;<a style="text-decoration: none;color: #818180;position: relative;top: 8px;" href="javascript:agregarFavorito('<?php echo $row->getId(); ?>')">Guardar</a>&nbsp;&nbsp;&nbsp;&nbsp;<a class="botonPago" href="<?php echo url_for('carrito/agregarCarrito?idDocumento='.$row->getId()) ?>"><?php if($row->getTipoDocumentoPago()=="2"){ echo '$ '.strtolower( $row->getPrecio()); }else { echo "Gratis"; } ?></a></li>
                    </ul>
                </div>
            </div>
           <hr style="width: 96%;margin: 15px 0px;">
            <?php endforeach; ?>
            <?php endif; ?>
            
            
        </div>
        
    </section>
    <script type="text/javascript">
    
           function mostarDetalle(id)
           {               
               $.ajax({
                  url:     '<?php echo url_for('@ajaxContentDetalle') ?>',
                  data:    { idDocumento : id },
                  success: function(data)
                  {
                        $.fancybox({
                            'content' : data
                          });
                  }
                 });
           }
               
           function agregarFavorito(id)
           {
               
               $.ajax({
                  url:     '<?php echo url_for('@ajaxAgregarFavorito') ?>',
                  data:    { idDocumento : id },
                  success: function(data)
                  {
                        
                  }
                 });
           }
                
          
          
              
           
  </script>